package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
* @author rdxcf
* @description 针对表【dish(菜品)】的数据库操作Mapper
* @createDate 2024-08-31 21:20:13
* @Entity mappers.domain.Dish
*/
@Mapper
public interface DishMapper {

    @Select("select count(id) from dish where category_id=#{id}")
    Integer countByCategoryId(Long id);

    @AutoFill(OperationType.INSERT)
    void insert(Dish dish);

    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    @Select("select * from dish where id=#{id}")
    Dish getById(Long id);

    @Delete("delete from dish where id=#{id}")
    void deleteById(Long id);

    void deleteByIds(List<Long> ids);

    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    List<Dish> list(Dish dish);

    @Select("select d.* from dish d join setmeal_dish sd on d.id = sd.dish_id where sd.setmeal_id=#{setmealId}")
    List<Dish> getBySetmealId(Long setmealId);

    Integer countByMap(Map<String, Object> map);
}




